<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
  <title>欢迎使用领捷智慧物流管理系统</title>
  <link rel="hshortcut icon" href="../static/img/own/head.png"/>
  <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
  <link rel="stylesheet" href="/static/fonts/fontawesome-all.min.css">
</head>

<body>
<div id="wrapper">
  <div class="d-flex flex-column" id="content-wrapper">
    <div id="content">
      <div class="container border rounded" style="min-width: 100%;width: auto;margin-bottom: 0px;padding: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;height: auto;margin-right: 0px;">
        <div class="row" style="margin-right: 0px;margin-left: 0px;">
          <div class="col" style="margin-left: 24px;padding: 13px;background: #ffffff;margin-right: 24px;"><span style="font-size: 25px;color: rgb(0,0,0);padding-left: 0px;">填写信息：</span></div>
        </div>
      </div>
      <div class="container border rounded" style="min-width: 100%;width: auto;margin-bottom: 0px;padding: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;height: auto;margin-right: 0px;">
        <form action="/stock/input" method="post" onsubmit="return fabu(this)" class="border rounded d-inline-flex flex-column justify-content-start justify-content-xl-start" style="background: #ffffff;margin-right: 24px;margin-left: 24px;opacity: 1;margin-top: 4px;padding: 12px;width: 1038px;"><span style="font-size: 18px;color: rgb(0,0,0);margin-left: 21px;margin-top: 0px;padding: 0px;padding-top: 0px;width: auto;">基本信息</span>
          <div class="form-group text-monospace text-center d-inline-flex justify-content-center visible" style="width: auto;padding-right: 0px;"
               ><span style="color: rgb(0,0,0);font-size: 16px;line-height: 40px;">&nbsp;入库单号&nbsp;</span><input class="form-control" type="text" style="width: 350px;margin-left: 10px;" th:value="${orderid}" name="orderid" readonly></div>
          <div class="form-group text-monospace text-center d-inline-flex justify-content-center visible" style="width: auto;padding-right: 0px;"
               ><span style="color: rgb(0,0,0);font-size: 16px;line-height: 40px;">&nbsp;商品编号&nbsp;</span><input class="form-control" type="text" style="width: 350px;margin-left: 10px;" th:value="${goodsid}" name="goodsid" readonly></div>
          <div class="form-group text-monospace text-center d-inline-flex justify-content-center visible" style="width: auto;padding-right: 0px;"
               ><span style="color: rgb(0,0,0);font-size: 16px;line-height: 40px;">&nbsp;商品数量&nbsp;</span><input class="form-control" type="text" style="width: 350px;margin-left: 10px;" th:value="${goodsnum}" name="goodsnum" readonly></div>
          <div class="form-group text-monospace text-center d-inline-flex justify-content-center" style="height: auto;margin-left: 0px;margin-right: 0px;width: auto;max-height: 100%;padding-left: 0px;">
            <span style="color: rgb(0,0,0);line-height: 40px;">选择仓库</span>
            <select class="form-control" style="width: 350px;margin-left: 10px;" name="housename" id="housename">
              <option value="0" name='warehouse'>请选择</option>
            </select>
          </div>
          <div class="form-group text-monospace text-center d-inline-flex justify-content-center" style="height: auto;margin-left: 0px;margin-right: 0px;width: auto;max-height: 100%;padding-left: 0px;">
            <span style="color: rgb(0,0,0);line-height: 40px;">选择片区</span>
            <select class="form-control" style="width: 350px;margin-left: 10px;" name="pianqu" id="pianqu">
              <option value="0" name='pianqu'>请先选择仓库</option>
            </select>
          </div>
          <div class="form-group text-monospace text-center d-inline-flex justify-content-center" style="height: auto;margin-left: 0px;margin-right: 0px;width: auto;max-height: 100%;padding-left: 0px;">
            <span style="color: rgb(0,0,0);line-height: 40px;">选择货架</span>
            <select class="form-control" style="width: 350px;margin-left: 10px;" name="huojia" id="huojia">
              <option value="0" name="huojia">请先选择片区</option>
            </select>
          </div>
          <div class="form-group text-monospace text-center d-inline-flex justify-content-center" style="height: auto;margin-left: 0px;margin-right: 0px;width: auto;max-height: 100%;padding-left: 0px;">
            <span style="color: rgb(0,0,0);line-height: 40px;">选择货架号</span>
            <select class="form-control" style="width: 350px;margin-left: 10px;" name="huojiahao" id="huojiahao">
              <option value="0" name="huojiahao">请先选择货架</option>
            </select>
          </div>

          <div class="form-group text-monospace text-center d-inline-flex justify-content-center"
               style="height: auto;margin-left: 0px;margin-right: 0px;width: auto;max-height: 100%;padding-left: 0px;">
            <button class="btn btn-primary" style="width: 80px;" type="submit" value="fabu">发布</button>
            <button class="btn btn-primary" type="button" style="width: 80px;margin-left: 10px;" id="fanhui">返回</button></div>
        </form>
      </div>
    </div>
    <footer class="bg-white sticky-footer">
      <div class="container my-auto">
        <div class="text-center my-auto copyright"><span>鄂ICP备2021022432号</span></div>
      </div>
    </footer>
  </div><a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a></div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/js/chart.min.js"></script>
<script src="/static/js/bs-init.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
<script src="/static/js/theme.js"></script>
<script src="/static/js/jquery.session.js"></script>


<script>

  // 初始化仓库下拉框
  $(document).ready(function (){
    $.ajax({
      url: "/stock/findAllWarehouseName",
      type: 'post',
      dataType:"json",
      success:function (result){
        $("#housename").empty();
        $("#housename").prepend("<option value='0' name='warehouse'>请选择</option>");
        let str = "";
        for(let i = 0; i < result.length; i++){
          $("#housename").append("<option name='warehouse'>"+result[i]+"</option>");
        }
      }
    })
    // alert($("#housename").find('option:selected').val());
  })

  //改变仓库下拉框获取片区
  $(function () {
    $("#housename").change(function () {
      var housename=$(this).find('option:selected').val();
        $("#pianqu").empty();
        $("#pianqu").prepend("<option value='0' name='pianqu'>请先选择仓库</option>");
        $("#huojia").empty();
        $("#huojia").prepend("<option value='0' name='huojia'>请先选择片区</option>");
        $("#huojiahao").empty();
        $("#huojiahao").prepend("<option value='0' name='huojiahao'>请先选择片区</option>");

        $.ajax({
          url : "/stock/findAllPianQuByWareHouseName",
          async : false,
          type : "POST",
          data : {"housename":housename},
          dataType: 'json',
          cache : false,
          success: function(result){
            $("#pianqu").empty();
            $("#pianqu").prepend("<option value='0' name='pianqu'>请选择</option>");
            for(let i = 0; i < result.length; i++){
              $("#pianqu").append("<option name='pianqu'>"+result[i]+"</option>");
            }
          }
        });

    });
  });

  //改变片区下拉框选择货架
  $(function () {
    $("#pianqu").change(function () {
      var housename = $("#housename").find('option:selected').val();
      var pianqu=$(this).find('option:selected').val();

        $("#huojia").empty();
        $("#huojia").prepend("<option value='0' name='huojia'>请先选择片区</option>");
        $("#huojiahao").empty();
        $("#huojiahao").prepend("<option value='0' name='huojiahao'>请先选择片区</option>");

        $.ajax({
          url : "/stock/findAllHuoJiaByHouseIdAndPianQu",
          async : false,
          type : "POST",
          data : {"housename":housename,"pianqu":pianqu},
          dataType: 'json',
          cache : false,
          success: function(result){
            $("#huojia").empty();
            $("#huojia").prepend("<option value='0' name='huojia'>请选择</option>");
            for(let i = 0; i < result.length; i++){
              $("#huojia").append("<option name='huojia'>"+result[i]+"</option>");
            }
          }
        });

    });
  });

  //改变货架下拉框选择货架号
  $(function () {
    $("#huojia").change(function () {
      var housename = $("#housename").find('option:selected').val();
      var pianqu = $("#pianqu").find('option:selected').val();
      var huojia = $("#huojia").find('option:selected').val();


        $("#huojiahao").empty();
        $("#huojiahao").prepend("<option value='0' name='huojiahao'>请先选择货架</option>");

        $.ajax({
          url : "/stock/findAllHuoJiaHaoByHouseIdAndPianQuAndHuoJia",
          async : false,
          type : "POST",
          data : {"housename":housename,"pianqu":pianqu,"huojia":huojia},
          dataType: 'json',
          cache : false,
          success: function(result){
            $("#huojiahao").empty();
            $("#huojiahao").prepend("<option value='0' name='huojiahao'>请选择</option>");
            for(let i = 0; i < result.length; i++){
              $("#huojiahao").append("<option name='huojiahao'>"+result[i]+"</option>");
            }
          }
        });

    });
  });


  // // 跳转订单页面
  // $(function (){
  //   $("#fanhui").click(function (){
  //     $(location).attr("href","/page/toOrder")
  //   })
  // })
  //

  function fabu(formvalue){
    // var warehouse = formvalue.warehouse.value;
    // var pianqu = formvalue.pianqu.value;
    // var huojia = formvalue.huojia.value;
    // var huojiahao = formvalue.huojiahao.value;

    var housename = $("#housename").find('option:selected').val();
    var pianqu = $("#pianqu").find('option:selected').val();
    var huojia = $("#huojia").find('option:selected').val();
    var huojiahao = $("#huojiahao").find('option:selected').val();

    var isSubmit = true;
    if(0==housename||0==pianqu||0==huojia||0==huojiahao){
      isSubmit = false;
    }
    if(!isSubmit){
      alert("请不要输入空值！");
      return false;
    }
  }

  $(function (){
    $("#fanhui").on("click",function (){
      $(location).attr("href","/page/toInwarehouse");
    })
  })

  //session
  $.session.set("url",window.location.href);

</script>
</body>

</html>